Onshape 零組件繪製 <<
Previous Next >> MTB_robot add suction pad
CoppeliaSim 4.1.0 MTB robot
W16_exam
影片:
Tips:要注意的是程式內部的名稱要跟軸的名字一樣,否則無法作動

程式碼:
function sysCall_init()
-- do some initialization here
axis1=sim.getObjectHandle('MTB_axis1')
axis1=sim.getObjectHandle('MTB_axis2')
axis3=sim.getObjectHandle('MTB_axis3')
axis4=sim.getObjectHandle('MTB_axis4')
rotation1 = 0
distance3 = 0
deg = math.pi/180
--sim.sJointTargetVelocity(joint,5.5)
end
function sysCall_actuation()
calibration = 0.0042
message,auxiliaryData=sim.getSimulatorMessage()
if (message==sim.message_keypress) then
print(auxiliaryData[1])--key
if (auxiliaryData[1]==string.byte(' ')) then
end
if (auxiliaryData[1]==97) then--a
rotation1 = rotation1 + 5*deg
--逆時針轉每按一次增加5度
sim.setJointPosition(axis1, rotation1)
end
if (auxiliaryData[1]==100) then --d
rotation1 = rotation1 - 5*deg
--順時針轉每按一次減少5度
sim.setJointPosition(axis1, rotation1)
end
if (auxiliaryData[1]==119) then --s
distance3 = distance3 + 0.01 + calibration
--每按一次s軸就向下多0.01
sim.setJointPosition(axis3, distance3)
end
if (auxiliaryData[1]==115) then --w
distance3 = distance3 - 0.01 - calibration
--每按一次w軸就向上多0.01
sim.setJointPosition(axis3, distance3)
end
end
end
function sysCall_sensing()
-- put your sensing code here
end
function sysCall_cleanup()
-- do some clean-up here
end
-- See the user manual or the available code snippets for additional callback functions and details
Onshape 零組件繪製 <<
Previous Next >> MTB_robot add suction pad